home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’87 / Source ƒ.sit / Source ƒ / C ƒ / CITADEL BBS 'C' SRC / LIBNET.C < prev    next >
C/C++ Source or Header  |  1987-01-14  |  2KB  |  69 lines

  1. /************************************************************************/
  2. /*                libnet.c                */
  3. /*                                    */
  4. /*             Library net functions                */
  5. /************************************************************************/
  6.  
  7. /************************************************************************/
  8. /*                history                 */
  9. /*                                    */
  10. /* 85Nov15 HAW    Created.                        */
  11. /************************************************************************/
  12.  
  13. #include "ctdl.h"
  14.  
  15. struct netBuffer netBuf;
  16. extern struct netTable    *netTab;
  17. int         thisNet;
  18. FILE         *netfl;
  19.  
  20. /************************************************************************/
  21. /*                contents                */
  22. /*                                    */
  23. /*    getNet()        gets a node from CTDLNET.SYS        */
  24. /*    putNet()        puts a node to CTDLNET.SYS        */
  25. /************************************************************************/
  26.  
  27. /************************************************************************/
  28. /*    getNet() Gets a net node from the file.             */
  29. /************************************************************************/
  30. getNet(n)
  31. int n;
  32. {
  33.     long int r, s;
  34.  
  35.     thisNet = n;
  36.     r = sizeof netBuf;
  37.     s = n * r;
  38.  
  39.     fseek(netfl, s, 0);
  40.     if (fread(&netBuf, sizeof netBuf, 1, netfl) != 1) {
  41.     crashout("?getNet-read fail!!");
  42.     }
  43.     crypte(&netBuf, sizeof netBuf, n);
  44. }
  45.  
  46. /************************************************************************/
  47. /*    putNet() put node to file                    */
  48. /************************************************************************/
  49. putNet(n)
  50. int n;
  51. {
  52.     long int r, s;
  53.  
  54.     thisNet = n;
  55.     netTab[n].ntflags.in_use      = netBuf.nbflags.in_use     ;
  56.     netTab[n].ntflags.room_files  = netBuf.nbflags.room_files ;
  57.     netTab[n].ntflags.normal_mail = netBuf.nbflags.normal_mail;
  58.     netTab[n].ntflags.local      = netBuf.nbflags.local;
  59.     r = sizeof netBuf;
  60.     s = n * r;
  61.     crypte(&netBuf, sizeof netBuf, n);
  62.  
  63.     fseek(netfl, s, 0);
  64.     if (fwrite(&netBuf, sizeof netBuf, 1, netfl) != 1) {
  65.     crashout("?getNet-write fail!!");
  66.     }
  67.     crypte(&netBuf, sizeof netBuf, n);
  68. }
  69.